//
//  DDRankTableViewCell.m
//  DDMusic
//
//  Created by rimi on 16/11/10.
//  Copyright © 2016年 FengBaoFamily. All rights reserved.
//

#import "DDRankTableViewCell.h"
#import "UILabel+DDUILabelCategory.h"
#import <Masonry.h>
#import <UIImageView+WebCache.h>
@interface DDRankTableViewCell()
@property (nonatomic,strong) UILabel* rankNumberLabel;//排行数字的label
@property (nonatomic,strong) UIImageView* rankMusicImageView;//排行歌曲的图片
@property (nonatomic,strong) UILabel* rankMusicNameLabel;//排行歌曲名
@property (nonatomic,strong) UILabel* rankMusicSingerNameLabel;//排行歌手名


@end
@implementation DDRankTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self layoutUI];
    }
    return self;
}
#pragma mark 布局UI
- (void)layoutUI{
//rankNumberLabel
    self.rankNumberLabel = [UILabel dd_CreatLabelWithTitle:@"" font:20 TitleColor:[UIColor lightGrayColor] TextAlignment:(NSTextAlignmentLeft)];
    [self.contentView addSubview:self.rankNumberLabel];
    __weak DDRankTableViewCell* weakSelf = self;
    [self.rankNumberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(weakSelf.mas_centerY);
        make.left.equalTo(@16);
    }];
//rankMusicImageView
    self.rankMusicImageView = [[UIImageView alloc]init];
    [self.contentView addSubview:self.rankMusicImageView];
    [self.rankMusicImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.rankNumberLabel.mas_right).offset(16);
        make.top.equalTo(@8);
        make.bottom.equalTo(@(-8));
        make.width.equalTo(@44);
    }];
//rankMusicNameLabel
    self.rankMusicNameLabel = [UILabel dd_CreatLabelWithTitle:@"" font:17 TitleColor:[UIColor blackColor] TextAlignment:(NSTextAlignmentLeft)];
    [self.contentView addSubview:self.rankMusicNameLabel];
    [self.rankMusicNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.rankMusicImageView.mas_top);
        make.left.equalTo(weakSelf.rankMusicImageView.mas_right).offset(16);
    }];

//rankMusicSingerNameLabel
    self.rankMusicSingerNameLabel = [UILabel dd_CreatLabelWithTitle:@"" font:15 TitleColor:[UIColor blackColor] TextAlignment:(NSTextAlignmentLeft)];
    [self.contentView addSubview:self.rankMusicSingerNameLabel];
    [self.rankMusicSingerNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(weakSelf.rankMusicImageView.mas_bottom);
        make.left.equalTo(weakSelf.rankMusicNameLabel.mas_left);
    }];

}

- (void)setModel:(DDMusicModel *)model{
    _model = model;
    self.rankMusicNameLabel.text = _model.songname;
    self.rankMusicSingerNameLabel.text =model.singername;
    [self.rankMusicImageView sd_setImageWithURL:[NSURL URLWithString:_model.albumpic_big] placeholderImage:[UIImage imageNamed:@""]];
    self.rankNumberLabel.text = _model.rankNumber;
}

@end
